package cloud.zhixinglu.www.spring.boot.rocketmq.controller;

import cloud.zhixinglu.www.spring.boot.rocketmq.pojo.vo.RocketMessage;
import lombok.Setter;
import org.apache.rocketmq.spring.core.RocketMQTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.time.LocalDateTime;

/**
 * <p>
 * NormalProduceController
 * </p>
 *
 * @author weixin
 * @date 2023/4/12 14:59
 */
@RestController
public class NormalProduceController {

    @Setter(onMethod_ = @Autowired)
    private RocketMQTemplate rocketmqTemplate;

    @GetMapping("/test")
    public void test(){
        //普通消息无返回值，只负责发送消息⽽不等待服务器回应且没有回调函数触发。
        RocketMessage rocketMessage = RocketMessage.builder().
                id(1111L).
                message("hello,world")
                .localDate(LocalDate.now())
                .localDateTime(LocalDateTime.now())
                .build();
        rocketmqTemplate.convertAndSend(rocketMessage);
    }

}
